#ifndef PARSERBNF_HH
#define PARSERBNF_HH

#include <iostream>
#include <string>
#include <list>
#include <map>
#include <vector>

#include "MyException.h"
#include "IBNF.h"

class StaticBNF : public IBNF
{
public:

  enum operators
    {
      O_PLUS = '+',
      O_MOINS = '-',
      O_EGAL = '=',
      O_SUP = '>',
      O_INF = '<'
    };

  enum expected
    {
      VAR,
      OPERAOR,
      VINCLUDE,
      CODE,
      ELSE,
      NONE
    };

  enum keys
    {
      BEGIN,
      DECL,
      COND,
      OPERANDE,
      INCLUDE,
      ECHO,
      COMMENT,
      END
    };

  struct lex
  {
    StaticBNF::expected			exp;
    StaticBNF::keys			key;
    std::string				cpp;
    std::string				cpp_end;
    std::string				lol;
    std::string				lol_end;
    std::map<std::string, std::string>	convert_args;
    bool				do_convert;
    int					priority;
  };

public:
  StaticBNF(std::map<std::string, std::string> &);
  virtual ~StaticBNF();
  StaticBNF(StaticBNF &);
  StaticBNF &	operator=(StaticBNF &);

  std::string	translate(std::string);
  bool		priority(std::string);

private:
  std::list<lex*>			library;
  std::map<std::string, std::string>	varmap;

  void				createScannerMap(void);
  void				tokenize(const std::string &,
					 std::vector<std::string> &,
					 const std::string &);
  lex *				scan(std::string &);
  bool				check(std::string &, lex *);

  void				manageOperators(std::string &);
  lex *				buildHAI(void);
  lex *				buildCANHAS(void);
  lex *				buildVISIBLE(void);
  lex *				buildBTW(void);
  lex *				buildKTHXBYE(void);
  lex *				buildGTFO(void);
  lex *				buildKTHX(void);
  lex *				buildIZ(void);
  lex *				buildNOWAI(void);
  lex *				buildIHASA(void);
  lex *				buildDIAF(void);
  lex *				buildLOL(void);
  lex *				buildIMINYR(void);
  lex *				buildYARLY(void);
  lex *				buildBYES(void);
  lex *				buildUPZ(void);
  lex *				buildNERFZ(void);
  lex *				buildTIMEZD(void);
  lex *				buildOVARZ(void);
  lex *				buildGIMMEH(void);

};

#endif
